'''
Created on Jan 2013

@author: dexen
'''

import time
import random

import dexen

from individual_b import Individual
from grid import Grid
                    
class DevTask(dexen.BaseSlaveTask):
    def __init__(self):
        pass

    def __execute__(self, master_state, inds):
        for ind in inds:
            print "id = ", inds[0]._get_id(), type(inds[0]._get_id())
            grid = Grid(10,10)
            for gene in ind.genotype:
                growth_points = grid.get_growth_points()
                if growth_points:
                    point = growth_points[floor(gene * len(growth_points))]
                    grid.set_point_on(point)
                else:
                    root_points = grid.get_root_points()
                    if root_points:
                        point = root_points[floor(gene * len(root_points))]
                        grid.set_point_on(point)
            ind.phenotype = grid
            ind.archive_data("phenotype.txt", str(grid))
        return inds
            
